<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../vue.js"></script><style>
        div#app {
        width:250px;
        margin: 30px auto;
        border: 1px solid □#666; 
        border-radius:10px; padding:10px;
    }
        
        p {
        text-align: center;
        }
        </style>
</head>
<body>
        
    <div id="app">
        <p>
        <input type="text" placeholder="猜数字"v-model="gueassed">
    </p >
    <p>
        {{res}}
        </p >
    </div>
    <script>
        new Vue({
        el: '#app', 
        data:{
            gueassed:'',
            // 生成随机数0-100
            a:Math.floor(Math.random() * 100),
        },
        computed:{
            res:{
                //当有人读取fantcc，就会调用get， 
                get() {
                    const b = this.gueassed * 1; 
                    const a = this.a

                    if (a == b)
                    return"恭喜你猜对了" 
                    if (b == 0)
                    return "请猜一个介于1和100之间的整数"; 
                    if (b > a)
                    return"大了，往大一点猜" 
                    if (b < a)
                    return"小了，往大一点猜"
                    },
                    }	}	
                    })
        </script>
</body>
</html>